<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>OpenSim on EC2</title>
  <link rel="stylesheet" type="text/css" href="css/scratchpad.css">
  <script src="js/sha1.js"></script>
  <script src="js/base64.js"></script>
  <script src="js/utils.js"></script>
  <script src="js/strftime.js"></script>
  <script src="js/model.js"></script>
  <script src="js/client.js"></script>
  <script src="js/controller.js"></script>
  <script src="js/settings.js"></script>
  <script src="js/state.js"></script>
  <script src="js/SimOnDemand-settings.json"></script>
</head>
<body bottommargin="0" rightmargin="0" leftmargin="0" topmargin="0"
 marginheight="0" marginwidth="0">
<table style="width: 100%;" align="center" border="0" cellpadding="0"
 cellspacing="0">
  <tbody>
    <tr>
      <td width="50%"><img style="width: 1px; height: 20px;"
 src="images/spacer.gif"></td>
      <td><img src="images/spacer.gif" height="1" width="700">
      <table width="100%">
        <tbody>
          <tr>
            <td nowrap="nowrap"><a href="opensim-ec2-launcher.html"><font
 class="logo">Sim On Demand</font><br>
            </a><font class="logoweb">Opensim On EC2 Launcher</font></td>
            <td align="right"><img src="images/poweredbyaws.png"
 hspace="5"></td>
          </tr>
        </tbody>
      </table>
      </td>
      <td width="50%"><img src="images/spacer.gif" height="1"
 width="100"></td>
    </tr>
    <tr>
    <td></td>
    <td style="text-align: right;"> 
    <h4>
	    <a
		href="javascript:displaySettings()"> Settings </a> &nbsp;&nbsp;<a
		href="help.html" TARGET="_blank"> Help</a> &nbsp;&nbsp;<a
		href="aboutus.html" TARGET="_blank">About Us</a> &nbsp;&nbsp;&nbsp;&nbsp;</td>
	</h4>
    <td></td>
    </tr>
	<tr>
	<td></td>
	<td>
		<table width="100%">
		  <tbody>
		    
		    <tr>
		      <td style="text-align: right; width: 30%;">
		      <div id="ControlArea"
		 style="align: right; border: 1px solid rgb(102, 153, 204); height: 150px; color: rgb(150, 102, 153); font-size: 13px; width: 150px;">
		Control Area </div>
		
		 		</td>
		      <td>
		      <div id="InfoArea"
		 style="height: 150px; color: rgb(150, 102, 153); font-size: 13px; width: 100%;">
		<br>Info Area <br> </div>
		      </td>
		    </tr>
		    <tr>
		    </tr>
		  </tbody>
		</table>
	 </td>
	<td></td>
	</tr>
	<tr>
	<td></td>
   <td>
   <div id="Debug">
     	<h4><a href="javascript:toggleVisibility(document.getElementById('DebugOut'));">
		 Toggle Debug Output
		 </a></h4> 
    	<textarea
 			style="border: 1px solid rgb(102, 153, 204); height: 150px; color: rgb(150, 102, 153); font-size: 13px; width: 100%;"
 			id="DebugOut" name="DebugOut" rows="3" cols="1">Debug output area</textarea>
   </div>
   </td>
	<td></td>
	</tr>
  </tbody>
</table>
<img src="images/spacer.gif" height="1" width="100">
<script>
				function Dbg(str)
				{
					//alert(str);
					document.getElementById('DebugOut').value += str + '\n';
				}
				function displayHelp()
				{
					Dbg('displayHelp');
				}
				function aboutUs()
				{
					Dbg('aboutUs');
				}
            function getAccessKeyId() {
                //return document.getElementById('AWSAccessKeyId').value;
                Dbg('getAccessKeyId'+SimOnDemandSettings["AWSAccessKeyId"]);
                return SimOnDemandSettings["AWSAccessKeyId"];
            
            }
            function getSecretAccessKey() {
                //return document.getElementById('AWSSecretAccessKey').value;
                Dbg('getSecretAccessKey' + SimOnDemandSettings["AWSSecretAccessKey"]);
                return SimOnDemandSettings["AWSSecretAccessKey"];
            
            }

            function getUniqueName() {
                return document.getElementById('UniqueName').value;
            
            }
            
				function OnClickControl()
				{
					InferState();
					if(MyState == "StartAfresh")
						{
						StartAfresh();
						return;
						}
					if(MyState == "Alive")
						{
						Dbg('Stopping Instance'); 
						StopRunningInstance();
						return
						}
					if( MyState == "Restart")
						{
						RestartInstance();
						return;
						}
				}
				function StartAfresh()
				{
					runOpensimInstance();
					InferState();
				}
				function StopRunningInstance()
				{
					terminateOpensimInstance();
					InferState();

				}
				function RestartInstance()
				{
					runOpensimInstance();
					//InferState();
				}
				function toggleVisibility(me)
				{
					if (me.style.visibility=="hidden")
					{
						me.style.visibility="visible";
					}
					else 
					{
						me.style.visibility="hidden";
					}
				}
				function reloadMe()
				{
					window.location.reload();
				}
				function transitionVisual()
				{
						Dbg('transitionVisual');
						document.getElementById("ControlArea").innerHTML = "<a> <img   border=\"0\" src=\"images/ajax-loader150.gif\"></a>";
				}
				function displaySettings()
				{
					Dbg('displaySettings');
					if(MyState == null)
						promptSettings();
					 else
					 	InferState();
					var array = ["AWSAccessKeyId", "AWSSecretAccessKey", "InitBucket", "UniqueId", "imageId", "keyName"];
					var myhtml = "<a href=\"javascript:window.location.reload();\"><img   border=\"0\" src=\"images/go.gif\"></a><br>";
					for (var i in array )
						{
							myhtml += 'SimOnDemandSettings[\'' + array[i] + '\'] is ' + SimOnDemandSettings[array[i]] + "<br>";
						}
					
					document.getElementById("InfoArea").innerHTML = myhtml;
				}
			toggleVisibility(document.getElementById('DebugOut'));
			Dbg('\nTrying loadSettingsFromFile');
			transitionVisual();
			var freshRun = null;
			settings = loadSettingsFromFile();
			eval(settings);
			if( freshRun)
				{
					Dbg('Application run for the first time... Prompt Settings');
					promptSettings();
				}
			else
				{
					Dbg('Settings from previous run detected:Infering State to continue...');
					InferState();
				}
			for (var i in SimOnDemandSettings )
						{
							Dbg('SimOnDemandSettings[\''+i+'\'] is ' + SimOnDemandSettings[i]);
						}
        
        </script>
</body>
</html>
